/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef <NAMESPACE>_<SUBSYS_NAME>_UTILS_<KEY_WORD>_HILOG_WRAPPER_H_
#define <NAMESPACE>_<SUBSYS_NAME>_UTILS_<KEY_WORD>_HILOG_WRAPPER_H_

#define CONFIG_HILOG
#ifdef CONFIG_HILOG
#include "hilog/log.h"
namespace <namespace> {
namespace <Subsys_name> {
#define __FILENAME__            (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
#define __FORMATED(fmt, ...)    "[%{public}s] %{public}s# " fmt, __FILENAME__, __FUNCTION__, ##__VA_ARGS__

#ifdef <KEY_WORD>_HILOGF
#undef <KEY_WORD>_HILOGF
#endif

#ifdef <KEY_WORD>_HILOGE
#undef <KEY_WORD>_HILOGE
#endif

#ifdef <KEY_WORD>_HILOGW
#undef <KEY_WORD>_HILOGW
#endif

#ifdef <KEY_WORD>_HILOGI
#undef <KEY_WORD>_HILOGI
#endif

#ifdef <KEY_WORD>_HILOGD
#undef <KEY_WORD>_HILOGD
#endif

enum <KEY_WORD>_MODULE {
    <KEY_WORD>_UTIL = 0,
    <KEY_WORD>_KITS,
    <KEY_WORD>_INNERKITS,
    <KEY_WORD>_JS_NAPI,
    <KEY_WORD>_SRV,
    <KEY_WORD>_TEST,
    <KEY_WORD>_BUTT
};
// In order to improve performance, do not check the module range.

static constexpr OHOS::HiviewDFX::HiLogLabel <KEY_WORD>_LABEL[<KEY_WORD>_BUTT] = {
    {LOG_CORE, <KEY_WORD>_UTIL,            "<Key_word>Utils"},
    {LOG_CORE, <KEY_WORD>_KITS,            "<Key_word>Kits"},
    {LOG_CORE, <KEY_WORD>_INNERKITS,       "<Key_word>InnerKits"},
    {LOG_CORE, <KEY_WORD>_JS_NAPI,         "<Key_word>JsNapi"},
    {LOG_CORE, <KEY_WORD>_SRV,             "<Key_word>Srv"},
    {LOG_CORE, <KEY_WORD>_TEST,            "<Key_word>Test"}
};

// Besides, make sure module is less than POWERMGR_MODULE_BUTT.
#define <KEY_WORD>_HILOGF(module, ...) (void)OHOS::HiviewDFX::HiLog::Fatal(<KEY_WORD>_LABEL[module], __FORMATED(__VA_ARGS__))
#define <KEY_WORD>_HILOGE(module, ...) (void)OHOS::HiviewDFX::HiLog::Error(<KEY_WORD>_LABEL[module], __FORMATED(__VA_ARGS__))
#define <KEY_WORD>_HILOGW(module, ...) (void)OHOS::HiviewDFX::HiLog::Warn(<KEY_WORD>_LABEL[module], __FORMATED(__VA_ARGS__))
#define <KEY_WORD>_HILOGI(module, ...) (void)OHOS::HiviewDFX::HiLog::Info(<KEY_WORD>_LABEL[module], __FORMATED(__VA_ARGS__))
#define <KEY_WORD>_HILOGD(module, ...) (void)OHOS::HiviewDFX::HiLog::Debug(<KEY_WORD>_LABEL[module], __FORMATED(__VA_ARGS__))

} // namespace <Subsys_name>
} // namespace <namespace>

#else

#define <KEY_WORD>_HILOGF(...)
#define <KEY_WORD>_HILOGE(...)
#define <KEY_WORD>_HILOGW(...)
#define <KEY_WORD>_HILOGI(...)
#define <KEY_WORD>_HILOGD(...)

#endif // CONFIG_HILOG

#endif // <NAMESPACE>_<SUBSYS_NAME>_UTILS_<KEY_WORD>_HILOG_WRAPPER_H_
